package thu.infinity.commons;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

import thu.infinity.thrift.Aggregator;
import thu.infinity.thrift.UserToken;


public class InfinityClient {
	public static void main(String[] args) {
		try {
			TTransport transport = new TSocket("localhost", 9999);
			TProtocol protocol = new TBinaryProtocol(transport);
			Aggregator.Client client = new Aggregator.Client(protocol);

			transport.open();
			
			System.out.println ("Sucessfully login");
		
			String yhGuoId = "100002572131516";//"100002572131516"; // Yihua Guo
			String yhGuoAcTok = "AAACEdEose0cBAKInWNLJkYb8XazzGVZCZAWsC7XJfAHnjuzFfoa4UBzTLFUU2i0XPJKR1EAyUmA5jNOksntpkmwFqVcvvOITcqN8XiHXNwedvW1Qft";
			String ydGaoId = "1336341331"; // Yudong Gao
			String ydGaoAcTok = "145634995501895|1a94eae701d26809043e1dbc.1-1336341331|SJdJshNkv5tBRaarnqFLwkr1ge4";
			
			UserToken ut = new UserToken();
			ut.uid = yhGuoId;
			
			System.out.println("Starting first login");
			client.backend_login(yhGuoId, yhGuoAcTok, "Facebook");
			System.out.println("After first login");
			
		} catch (TException x) {
			System.out.println("Connection dropped");
			
			x.printStackTrace();
		}
	}
}